# Maintainer: Maxime Gauduin <alucryd@archlinux.org>

pkgname=emby-theater
pkgver=3.0.19
_libmpv_ver=2022_12_01
pkgrel=2
pkgdesc='An Electron app for Emby'
arch=(loong64 x86_64)
url=https://emby.media
license=(GPL2)
depends=(
  at-spi2-atk
  at-spi2-core
  cairo
  gcc-libs
  glibc
  libasound.so
  libatk-1.0.so
  libcups
  libdbus-1.so
  libdrm
  libexpat.so
  libfontconfig.so
  libfreetype.so
  libgdk-3.so
  libgdk_pixbuf-2.0.so
  libgio-2.0.so
  libglib-2.0.so
  libgobject-2.0.so
  libgtk-3.so
  libmfx
  libpango-1.0.so
  libpangocairo-1.0.so
  libpulse.so
  libuuid.so
  libva-drm.so
  libva.so
  libx11
  libxcb
  libxcomposite
  libxcursor
  libxdamage
  libxext
  libxfixes
  libxi
  libxrandr
  libxrender
  libxss
  libxtst
  mesa
  nspr
  nss
  ocl-icd
  zlib
)
makedepends=(
  git
  npm
)
optdepends=(
  'libcec: HDMI-CEC support'
)
_tag=915af80eeba533e3014192708ca3b722046fad03
source=(
  git+https://github.com/MediaBrowser/emby-theater-electron.git#tag=${_tag}
  https://mediabrowser.github.io/embytools/libmpv-${_libmpv_ver}-x64.tar.xz
  emby-theater.desktop
  emby-theater.png
)
b2sums=('SKIP'
        '7c8d0c95bd9275a17739fdfb17d55a5d38d7a771a464e28bdeff075a4947beddf52f386e8e57627819ce85306faa59ef6d579286dca5144795eb2c74e29c286b'
        '33b1230792bfc034d28fed21c60f9ecb3d7392293289a878866a20a505acabd03848df92300c9b1fd76d40ff03a6926451308c2b525ded0a75a17b77672c1e3b'
        '130bcfad0a216d66e44e3551af14700b3745d55b89c4523543646ae0d1fc00f6787ad8ace827a47f0f671d340308e4529c91f1c018002e64c89cb0ca924aeb4b')

prepare() {
  cd emby-theater-electron
  npm install
  npm install electron-packager
}

build() {
  cd emby-theater-electron
  npx electron-packager . emby-theater --platform linux --arch x64
}

package() {
  install -dm 755 "${pkgdir}"/usr/{bin,lib}
  cp -dr --no-preserve=ownership emby-theater-electron/emby-theater-linux-x64 "${pkgdir}"/usr/lib/emby-theater
  chmod 755 "${pkgdir}"/usr/lib/emby-theater
  rm -rf "${pkgdir}"/usr/lib/emby-theater/resources/app/libmpv/{arm,arm64,ia32,mpv-win32-*}
  ln -s /usr/lib/emby-theater/emby-theater "${pkgdir}"/usr/bin/emby-theater
  install -Dm 755  lib/libmpv.so.2.0.0 -t "${pkgdir}"/usr/lib/emby-theater/
  ln -s libmpv.so.2.0.0 "${pkgdir}"/usr/lib/emby-theater/libmpv.so.1
  install -Dm 644 emby-theater.desktop -t "${pkgdir}"/usr/share/applications/
  install -Dm 644 emby-theater.png -t "${pkgdir}"/usr/share/pixmaps/
}

# vim: ts=2 sw=2 et:
